1 /* Excerpts written by Martin Mares <mj@atrey.karlin.mff.cuni.cz> */
2 /* Modified for i386/x86-64 Xen by Keir Fraser */
4 #include <xen/config.h>
7 #include <asm/percpu.h>
13 #define FORMAT "pei-x86-64"
14 #undef __XEN_VIRT_START
15 #define __XEN_VIRT_START __image_base__
21 #define FORMAT "elf64-x86-64"
27 OUTPUT_FORMAT(FORMAT, FORMAT, FORMAT)
29 OUTPUT_ARCH(i386:x86-64)
34 #if defined(BUILD_ID) && !defined(EFI)
49 * We don't really use this symbol anywhere, and the way it would get defined
50 * here would result in it having a negative (wrapped to huge positive)
51 * offset relative to the .text section. That, in turn, causes an assembler
52 * truncation warning when including all symbols in the symbol table for Live
55 __2M_text_start = .; /* Start of 2M superpages, mapped RX. */
58 . = __XEN_VIRT_START + MB(1);
61 _stext = .; /* Text and read-only data */
68 _etext = .; /* End of text section */
78 __2M_rodata_start = .; /* Start of 2M superpages, mapped RO. */
81 /* Bug frames table */
83 __start_bug_frames = .;
85 __stop_bug_frames_0 = .;
87 __stop_bug_frames_1 = .;
89 __stop_bug_frames_2 = .;
91 __stop_bug_frames_3 = .;
96 #if defined(BUILD_ID) && defined(EFI)
98 * No mechanism to put an PT_NOTE in the EFI file - so put
99 * it in .rodata section. (notes.o supplies us with .note.gnu.build-id).
102 __note_gnu_build_id_start = .;
103 *(.note.gnu.build-id)
104 __note_gnu_build_id_end = .;
107 /* Exception table */
108 __start___ex_table = .;
110 __stop___ex_table = .;
112 /* Pre-exception table */
113 __start___pre_ex_table = .;
115 __stop___pre_ex_table = .;
117 #ifdef CONFIG_LOCK_PROFILE
118 . = ALIGN(POINTER_ALIGN);
119 __lock_profile_start = .;
121 __lock_profile_end = .;
125 #if defined(BUILD_ID) && !defined(EFI)
127 * What a strange section name. The reason is that on ELF builds this section
128 * is extracted to notes.o (which then is ingested in the EFI file). But the
129 * compiler may want to inject other things in the .note which we don't care
130 * about - hence this unique name.
133 .note.gnu.build-id : {
134 __note_gnu_build_id_start = .;
135 *(.note.gnu.build-id)
136 __note_gnu_build_id_end = .;
144 . = ALIGN(PAGE_SIZE);
148 __2M_init_start = .; /* Start of 2M superpages, mapped RWX (boot only). */
149 . = ALIGN(PAGE_SIZE); /* Init code and data */
155 * Here are the replacement instructions. The linker sticks them
156 * as binary blobs. The .altinstructions has enough data to get
157 * the address and the length of them to patch the kernel safely.
159 *(.altinstr_replacement)
167 . = ALIGN(POINTER_ALIGN);
172 __initcall_start = .;
173 *(.initcallpresmp.init)
174 __presmp_initcall_end = .;
182 __trampoline_rel_start = .;
184 __trampoline_rel_stop = .;
185 __trampoline_seg_start = .;
187 __trampoline_seg_stop = .;
189 * struct alt_inst entries. From the header (alternative.h):
190 * "Alternative instructions for different CPU types or capabilities"
191 * Think locking instructions on spinlocks.
194 __alt_instructions = .;
196 __alt_instructions_end = .;
207 . = ALIGN(PAGE_SIZE);
212 __2M_rwdata_start = .; /* Start of 2M superpages, mapped RW. */
213 . = ALIGN(SMP_CACHE_BYTES);
214 .data.read_mostly : {
217 __start_schedulers_array = .;
219 __end_schedulers_array = .;
225 . = ALIGN(PAGE_SIZE);
226 *(.data.page_aligned)
234 . = ALIGN(STACK_SIZE);
236 *(.bss.stack_aligned)
237 . = ALIGN(PAGE_SIZE);
238 *(.bss.page_aligned*)
240 . = ALIGN(SMP_CACHE_BYTES);
243 . = ALIGN(SMP_CACHE_BYTES);
244 *(.bss.percpu.read_mostly)
245 . = ALIGN(SMP_CACHE_BYTES);
246 __per_cpu_data_end = .;
254 . = ALIGN(PAGE_SIZE);
263 /* Trick the linker into setting the image size to exactly 16Mb. */
264 . = ALIGN(__section_alignment__);
272 /* Sections to be discarded */
286 /* Stabs debugging sections. */
287 .stab 0 : { *(.stab) }
288 .stabstr 0 : { *(.stabstr) }
289 .stab.excl 0 : { *(.stab.excl) }
290 .stab.exclstr 0 : { *(.stab.exclstr) }
291 .stab.index 0 : { *(.stab.index) }
292 .stab.indexstr 0 : { *(.stab.indexstr) }
293 .comment 0 : { *(.comment) }
296 ASSERT(__image_base__ > XEN_VIRT_START ||
297 _end <= XEN_VIRT_END - NR_CPUS * PAGE_SIZE,
298 "Xen image overlaps stubs area")
301 ASSERT(kexec_reloc_size - kexec_reloc <= PAGE_SIZE, "kexec_reloc is too large")
305 ASSERT(IS_ALIGNED(__2M_text_end, MB(2)), "__2M_text_end misaligned")
306 ASSERT(IS_ALIGNED(__2M_rodata_start, MB(2)), "__2M_rodata_start misaligned")
307 ASSERT(IS_ALIGNED(__2M_rodata_end, MB(2)), "__2M_rodata_end misaligned")
308 ASSERT(IS_ALIGNED(__2M_init_start, MB(2)), "__2M_init_start misaligned")
309 ASSERT(IS_ALIGNED(__2M_init_end, MB(2)), "__2M_init_end misaligned")
310 ASSERT(IS_ALIGNED(__2M_rwdata_start, MB(2)), "__2M_rwdata_start misaligned")
311 ASSERT(IS_ALIGNED(__2M_rwdata_end, MB(2)), "__2M_rwdata_end misaligned")
313 ASSERT(IS_ALIGNED(__2M_text_end, PAGE_SIZE), "__2M_text_end misaligned")
314 ASSERT(IS_ALIGNED(__2M_rodata_start, PAGE_SIZE), "__2M_rodata_start misaligned")
315 ASSERT(IS_ALIGNED(__2M_rodata_end, PAGE_SIZE), "__2M_rodata_end misaligned")
316 ASSERT(IS_ALIGNED(__2M_init_start, PAGE_SIZE), "__2M_init_start misaligned")
317 ASSERT(IS_ALIGNED(__2M_init_end, PAGE_SIZE), "__2M_init_end misaligned")
318 ASSERT(IS_ALIGNED(__2M_rwdata_start, PAGE_SIZE), "__2M_rwdata_start misaligned")
319 ASSERT(IS_ALIGNED(__2M_rwdata_end, PAGE_SIZE), "__2M_rwdata_end misaligned")
322 ASSERT(IS_ALIGNED(cpu0_stack, STACK_SIZE), "cpu0_stack misaligned")
324 ASSERT(IS_ALIGNED(__init_begin, PAGE_SIZE), "__init_begin misaligned")
325 ASSERT(IS_ALIGNED(__init_end, PAGE_SIZE), "__init_end misaligned")
327 ASSERT(IS_ALIGNED(trampoline_start, 4), "trampoline_start misaligned")
328 ASSERT(IS_ALIGNED(trampoline_end, 4), "trampoline_end misaligned")
329 ASSERT(IS_ALIGNED(__bss_start, 4), "__bss_start misaligned")
330 ASSERT(IS_ALIGNED(__bss_end, 4), "__bss_end misaligned")